package top.kuanghua.sms.utils.service;

import org.checkerframework.checker.units.qual.A;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.kuanghua.pojo.utils.NumberUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @Title: SendMsgService
 * @Description:
 * @Auther:
 * @create 2020/8/20 11:26
 */
@Service
public class SendMsgService {

    @Autowired
    protected AmqpTemplate amqpTemplate;

    public void sendMsg(String phone){
        String code = NumberUtils.generateCode(6);
        Map<String, String> smsMap = new HashMap<String, String>();
        smsMap.put("phone", phone);
        smsMap.put("code", code);
        amqpTemplate.convertAndSend("kuanghua.sms.exchange","sms.verify.code", smsMap);
    }
}



